import json
import os
from datetime import datetime, timedelta, timezone


# f_client=open('client_img_trans.txt', encoding='utf-8')
f_client=open('log_2024_04_17.txt', encoding='utf-8')
#此时只读取了一行
line = f_client.readline()
line = line.replace("\n","")
#利用循环全部读出
i = 1

count = 0
while line:
    line = f_client.readline()
    line = line.replace(" ", "")
    line = line.replace("\n", "")

    if "deadline" in line:
        aa = line.split(":")[2]
        product_id = aa[0]
        print(f"---------product_id: {product_id} , count:{count}")
        count = 0
    elif "startTime" in line:
        bb = line.split(",")
        start = bb[0].split(":")[1]
        end = bb[1].split(":")[1]
        count += 1
        print(f"---------time_gap: {int(end) - int(start)}")

f_client.close()



#
#
# with open('server_batch_time.json', mode='rb') as file:
#     all_server_log = json.load(file)
#     for item in all_server_log:
#         count = item["count_times"] * 5
#         float_seconds = item["time"]  # 这是一个示例值，代表某个具体日期
#         # 使用datetime模块中的datetime类来创建基准日期（这里是1970年1月1日）
#         base_date = datetime.fromtimestamp(0)
#         # 将浮点数转换为相对于基准日期的秒数（如果已经是秒数的话）
#         seconds_since_base = float_seconds
#         # 使用timedelta类来计算相对于基准日期的具体日期
#         date_object = base_date + timedelta(seconds=seconds_since_base)
#         time = date_object.strftime("%Y-%m-%d %H:%M:%S")
#         print(f"---------count: {count}, time:{time}")















